﻿#pragma once
#pragma execution_character_set("utf-8")
// 本文件为utf-8 编码格式

#ifndef __GD__GDHttpUtil__
#define __GD__GDHttpUtil__

#include "CrossApp.h"
#include "../CommonHttpManager.h"

class GDHttpUtil :
	public CAObject
{

public:
	static GDHttpUtil* getInstance();

	GDHttpUtil();

	virtual ~GDHttpUtil();

	void send_get(const std::string& url,
		std::map<std::string, std::string> key_value,
		CAObject* pTarget,
		SEL_CommonHttpJson pSelector,
		bool isLoading = false);

	void send_post(const std::string& url,
		std::map<std::string, std::string> key_value,
		CAObject* pTarget,
		SEL_CommonHttpJson pSelector,
		bool isLoading = false);

	void send_postFile(const std::string& url,
		std::map<std::string, std::string> key_value,
		const std::string& file,
		CAObject* pTarget,
		SEL_CommonHttpJson pSelector,
		bool isLoading = false);

	void onHttpRequestFinished(const HttpResponseStatus& status, const CSJson::Value& json);
	void onH5LoginFinished(const HttpResponseStatus& status, const CSJson::Value& json);
protected:
	/* 加工Url信息，将debug、token等信息添加进去 */
	std::string processUrl(std::string url);
private:
	std::string debugUrl; // 调试地址
	CAObject* pTarget;
	SEL_CommonHttpJson pSelector;
};
#endif /* defined(__HelloCpp__ViewController__) */